bluesky APIをPythonから呼び出す
blueskyのAPIをPythonから呼び出したい
今までbskyを使っていたが、返信周りで動かなくなってしまった
from 2024-09-06
https://qiita.com/ynack/items/85ccf951727f8ac48c6c
> bash
$ pip install atproto
<<
むー、よくわからないな・・
models.create_strong_ref を使いたいのだが・・
文字列のReplyは出来た
こういう感じ
- r = client.get_post_thread(uri=uri, depth = 1)
- ref = models.create_strong_ref(r.thread.post)
- client.send_post(text='test post', reply_to=models.AppBskyFeedPost.ReplyRef(parent=ref, root=ref))
- 複数画像のアップロード
- https://github.com/MarshalX/atproto/blob/main/examples/send_images.py
たぶん出来そう
- OGPの展開
- https://zenn.dev/sion_pn/articles/a725029649b0f8
- OGP画像が大きいのは大丈夫だよね?
- いや、ダメなのはこれだ
- この画像をリサイズする必要がある
- https://github.com/MarshalX/atproto/blob/main/examples/advanced_usage/send_ogp_link_card.py
- 公式サンプルがあった!
- 画像を送るか、Linkを送るかを決める必要あり
- 画像がついていればLinkは無視する感じになりそう
画像縮小
https://xtech.nikkei.com/atcl/nxt/column/18/02366/022700005/
これでいける?
> code
from PIL import Image
img = Image.open("src.jpg")
img.thumbnail((200,200))
img.save('out.jpg')
<<
できたっぽい。いったん縮小せず全部jpgにしてみる
PILでバイトデータから画像生成
- https://blog.goo.ne.jp/dak-ikd/e/ea620380baec995614fab9cf22b45f45
Pillow Imageをbytesに変換する
- https://zenn.dev/tamanobi/articles/88dacd450f8405c9a5a9
やりたい
2024-10-05~ ハッシュタグをちゃんと埋め込む
- {x} OGP画像のリサイズ
- {x} コマンドラインから起動
- 戻り値の処理
- {関係ない} reply先がない時の処理
- node側で対応できてるかも